<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.7"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>qLibc: containers/qhasharr.c File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">qLibc
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.7 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',false,false,'search.php','Search');
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('qhasharr_8c.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#define-members">Macros</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle"><div class="title">qhasharr.c File Reference</div></div>
</div><!--header-->
<div class="contents">

<p>Static(array) hash-table implementation.  
<a href="#details">More...</a></p>

<p><a href="qhasharr_8c_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="define-members" name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:af6ff8340308b20e6f2e5c2f024313c5d"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qhasharr_8c.html#af6ff8340308b20e6f2e5c2f024313c5d">COLLISION_MARK</a>&#160;&#160;&#160;(-1)</td></tr>
<tr class="separator:af6ff8340308b20e6f2e5c2f024313c5d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab725ad48f24a45370685c02f0005a78d"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qhasharr_8c.html#ab725ad48f24a45370685c02f0005a78d">EXTBLOCK_MARK</a>&#160;&#160;&#160;(-2)</td></tr>
<tr class="separator:ab725ad48f24a45370685c02f0005a78d"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a83012ec9fea85ca5770529997306334d"><td class="memItemLeft" align="right" valign="top">size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qhasharr_8c.html#a83012ec9fea85ca5770529997306334d">qhasharr_calculate_memsize</a> (int max)</td></tr>
<tr class="memdesc:a83012ec9fea85ca5770529997306334d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get how much memory is needed for N slots.  <br /></td></tr>
<tr class="separator:a83012ec9fea85ca5770529997306334d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6f5f9ed05bab0600c251949db75f76f1"><td class="memItemLeft" align="right" valign="top">qhasharr_t *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qhasharr_8c.html#a6f5f9ed05bab0600c251949db75f76f1">qhasharr</a> (void *memory, size_t memsize)</td></tr>
<tr class="memdesc:a6f5f9ed05bab0600c251949db75f76f1"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialize static hash table.  <br /></td></tr>
<tr class="separator:a6f5f9ed05bab0600c251949db75f76f1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6e43029429b7aa43a66d2b55ce3bac81"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qhasharr_8c.html#a6e43029429b7aa43a66d2b55ce3bac81">qhasharr_put</a> (qhasharr_t *tbl, const char *name, const void *data, size_t datasize)</td></tr>
<tr class="memdesc:a6e43029429b7aa43a66d2b55ce3bac81"><td class="mdescLeft">&#160;</td><td class="mdescRight">qhasharr-&gt;<a class="el" href="qhttpclient_8c.html#ae9ac3bd43c11509c0cbd8fb284bf13eb" title="qhttpclient-&gt;put(): Uploads a file to the remote host using PUT method.">put()</a>: Put an object into this table.  <br /></td></tr>
<tr class="separator:a6e43029429b7aa43a66d2b55ce3bac81"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aeadc9cda7a3e29e81a1f11b914c34390"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qhasharr_8c.html#aeadc9cda7a3e29e81a1f11b914c34390">qhasharr_putstr</a> (qhasharr_t *tbl, const char *name, const char *data)</td></tr>
<tr class="memdesc:aeadc9cda7a3e29e81a1f11b914c34390"><td class="mdescLeft">&#160;</td><td class="mdescRight">qhasharr-&gt;putstr(): Put a string into this table  <br /></td></tr>
<tr class="separator:aeadc9cda7a3e29e81a1f11b914c34390"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9df103f6016cd3d3267cdf42893ba809"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qhasharr_8c.html#a9df103f6016cd3d3267cdf42893ba809">qhasharr_putstrf</a> (qhasharr_t *tbl, const char *name, const char *format,...)</td></tr>
<tr class="memdesc:a9df103f6016cd3d3267cdf42893ba809"><td class="mdescLeft">&#160;</td><td class="mdescRight">qhasharr-&gt;putstrf(): Put a formatted string into this table.  <br /></td></tr>
<tr class="separator:a9df103f6016cd3d3267cdf42893ba809"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3bc56610cce2c4f7ee2373ae4a40143b"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qhasharr_8c.html#a3bc56610cce2c4f7ee2373ae4a40143b">qhasharr_put_by_obj</a> (qhasharr_t *tbl, const void *name, size_t namesize, const void *data, size_t datasize)</td></tr>
<tr class="memdesc:a3bc56610cce2c4f7ee2373ae4a40143b"><td class="mdescLeft">&#160;</td><td class="mdescRight">qhasharr-&gt;put_by_obj(): ut an object into this table by key object.  <br /></td></tr>
<tr class="separator:a3bc56610cce2c4f7ee2373ae4a40143b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a63f33bbeb824803c310e672f2ceb8c70"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qhasharr_8c.html#a63f33bbeb824803c310e672f2ceb8c70">qhasharr_get</a> (qhasharr_t *tbl, const char *name, size_t *datasize)</td></tr>
<tr class="memdesc:a63f33bbeb824803c310e672f2ceb8c70"><td class="mdescLeft">&#160;</td><td class="mdescRight">qhasharr-&gt;<a class="el" href="qhttpclient_8c.html#af16a3eb0912e8b5d4896466632d9c843" title="qhttpclient-&gt;get(): Downloads a file from the remote host using GET method.">get()</a>: Get an object from this table  <br /></td></tr>
<tr class="separator:a63f33bbeb824803c310e672f2ceb8c70"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a875e900cd73f72bcb613842ddf5b9c3a"><td class="memItemLeft" align="right" valign="top">char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qhasharr_8c.html#a875e900cd73f72bcb613842ddf5b9c3a">qhasharr_getstr</a> (qhasharr_t *tbl, const char *name)</td></tr>
<tr class="memdesc:a875e900cd73f72bcb613842ddf5b9c3a"><td class="mdescLeft">&#160;</td><td class="mdescRight">qhasharr-&gt;getstr(): Finds an object with given name and returns as string type.  <br /></td></tr>
<tr class="separator:a875e900cd73f72bcb613842ddf5b9c3a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9334082a845acb3edc1f62d337266acd"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qhasharr_8c.html#a9334082a845acb3edc1f62d337266acd">qhasharr_get_by_obj</a> (qhasharr_t *tbl, const void *name, size_t namesize, size_t *datasize)</td></tr>
<tr class="memdesc:a9334082a845acb3edc1f62d337266acd"><td class="mdescLeft">&#160;</td><td class="mdescRight">qhasharr-&gt;get_by_object(): Get an object from this table by key object  <br /></td></tr>
<tr class="separator:a9334082a845acb3edc1f62d337266acd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aac1f0f336ac79a12590a7f0993e09997"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qhasharr_8c.html#aac1f0f336ac79a12590a7f0993e09997">qhasharr_remove</a> (qhasharr_t *tbl, const char *name)</td></tr>
<tr class="memdesc:aac1f0f336ac79a12590a7f0993e09997"><td class="mdescLeft">&#160;</td><td class="mdescRight">qhasharr-&gt;remove(): Remove an object from this table.  <br /></td></tr>
<tr class="separator:aac1f0f336ac79a12590a7f0993e09997"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af57be2bc8caf66f6bf94cd21370ef44f"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qhasharr_8c.html#af57be2bc8caf66f6bf94cd21370ef44f">qhasharr_remove_by_obj</a> (qhasharr_t *tbl, const char *name, size_t namesize)</td></tr>
<tr class="memdesc:af57be2bc8caf66f6bf94cd21370ef44f"><td class="mdescLeft">&#160;</td><td class="mdescRight">qhasharr-&gt;remove_by_obj(): Remove an object from this table by key object  <br /></td></tr>
<tr class="separator:af57be2bc8caf66f6bf94cd21370ef44f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a54fa504cce007a18fa510be544307cab"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qhasharr_8c.html#a54fa504cce007a18fa510be544307cab">qhasharr_remove_by_idx</a> (qhasharr_t *tbl, int idx)</td></tr>
<tr class="memdesc:a54fa504cce007a18fa510be544307cab"><td class="mdescLeft">&#160;</td><td class="mdescRight">qhasharr-&gt;remove_by_idx(): Remove an object from this table by index number.  <br /></td></tr>
<tr class="separator:a54fa504cce007a18fa510be544307cab"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a88e2f56b1a87c1f9485f5343ec7998be"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qhasharr_8c.html#a88e2f56b1a87c1f9485f5343ec7998be">qhasharr_getnext</a> (qhasharr_t *tbl, qhasharr_obj_t *obj, int *idx)</td></tr>
<tr class="memdesc:a88e2f56b1a87c1f9485f5343ec7998be"><td class="mdescLeft">&#160;</td><td class="mdescRight">qhasharr-&gt;getnext(): Get next element.  <br /></td></tr>
<tr class="separator:a88e2f56b1a87c1f9485f5343ec7998be"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2a780affb950d666046cfb5e1f9c8153"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qhasharr_8c.html#a2a780affb950d666046cfb5e1f9c8153">qhasharr_size</a> (qhasharr_t *tbl, int *maxslots, int *usedslots)</td></tr>
<tr class="memdesc:a2a780affb950d666046cfb5e1f9c8153"><td class="mdescLeft">&#160;</td><td class="mdescRight">qhasharr-&gt;size(): Returns the number of objects in this table.  <br /></td></tr>
<tr class="separator:a2a780affb950d666046cfb5e1f9c8153"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0c0674e4d7ce39cf336067732ba8cb7b"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qhasharr_8c.html#a0c0674e4d7ce39cf336067732ba8cb7b">qhasharr_clear</a> (qhasharr_t *tbl)</td></tr>
<tr class="memdesc:a0c0674e4d7ce39cf336067732ba8cb7b"><td class="mdescLeft">&#160;</td><td class="mdescRight">qhasharr-&gt;clear(): Clears this table so that it contains no keys.  <br /></td></tr>
<tr class="separator:a0c0674e4d7ce39cf336067732ba8cb7b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6b95b3177af93236950694298df2b7e4"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qhasharr_8c.html#a6b95b3177af93236950694298df2b7e4">qhasharr_debug</a> (qhasharr_t *tbl, FILE *out)</td></tr>
<tr class="memdesc:a6b95b3177af93236950694298df2b7e4"><td class="mdescLeft">&#160;</td><td class="mdescRight">qhasharr-&gt;debug(): Print hash table for debugging purpose  <br /></td></tr>
<tr class="separator:a6b95b3177af93236950694298df2b7e4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa5cd6756ea7192366386e811c9da8cee"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qhasharr_8c.html#aa5cd6756ea7192366386e811c9da8cee">qhasharr_free</a> (qhasharr_t *tbl)</td></tr>
<tr class="memdesc:aa5cd6756ea7192366386e811c9da8cee"><td class="mdescLeft">&#160;</td><td class="mdescRight">qhasharr-&gt;free(): De-allocate table reference object.  <br /></td></tr>
<tr class="separator:aa5cd6756ea7192366386e811c9da8cee"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Static(array) hash-table implementation. </p>
<p>qhasharr implements a hash-table which maps keys to values and stores into fixed size static memory like shared-memory and memory-mapped file. The creator <a class="el" href="qhasharr_8c.html#a6f5f9ed05bab0600c251949db75f76f1" title="Initialize static hash table.">qhasharr()</a> initializes static memory to makes small slots in it. The default slot size factors are defined in Q_HASHARR_NAMESIZE and Q_HASHARR_DATASIZE. And they are applied at compile time.</p>
<p>The value part of an element will be stored across several slots if it's size exceeds the slot size. But the key part of an element will be truncated if the size exceeds and it's length and more complex MD5 hash value will be stored with the key. So to look up a particular key, first we find an element which has same hash value. If the key was not truncated, we just do key comparison. But if the key was truncated because it's length exceeds, we do both md5 and key comparison(only stored size) to verify that the key is same. So please be aware of that, theoretically there is a possibility we pick wrong element in case a key exceeds the limit, has same length and MD5 hash with lookup key. But this possibility is very low and almost zero in practice.</p>
<p>qhasharr hash-table does not provide thread-safe handling intentionally and let users determine whether to provide locking mechanism or not, depending on the use cases. When there's race conditions expected, you should provide a shared resource control using mutex or semaphore to make sure data gets updated by one instance at a time.</p>
<div class="fragment"><div class="line">[Data Structure Diagram]</div>
<div class="line"> </div>
<div class="line">+--[Static Flat Memory Area]-----------------------------------------------+</div>
<div class="line">| +-[Header]---------+ +-[Slot 0]---+ +-[Slot 1]---+        +-[Slot N]---+ |</div>
<div class="line">| |Private table data| |KEY A|DATA A| |KEY B|DATA B|  ....  |KEY N|DATA N| |</div>
<div class="line">| +------------------+ +------------+ +------------+        +------------+ |</div>
<div class="line">+--------------------------------------------------------------------------+</div>
<div class="line"> </div>
<div class="line">Below diagram shows how a big value is stored.</div>
<div class="line">+--[Static Flat Memory Area------------------------------------------------+</div>
<div class="line">| +--------+ +-[Slot 0]---+ +-[Slot 1]---+ +-[Slot 2]---+ +-[Slot 3]-----+ |</div>
<div class="line">| |TBL INFO| |KEY A|DATA A| |DATA A cont.| |KEY B|DATA B| |DATA A cont.  | |</div>
<div class="line">| +--------+ +------------+ +------------+ +------------+ +--------------+ |</div>
<div class="line">|                      ^~~link~~^     ^~~~~~~~~~link~~~~~~~~~^             |</div>
<div class="line">+--------------------------------------------------------------------------+</div>
</div><!-- fragment --><div class="fragment"><div class="line"><span class="comment">// initialize hash-table.</span></div>
<div class="line"><span class="keywordtype">char</span> memory[1000 * 10];</div>
<div class="line">qhasharr_t *tbl = <a class="code hl_function" href="qhasharr_8c.html#a6f5f9ed05bab0600c251949db75f76f1">qhasharr</a>(memory, <span class="keyword">sizeof</span>(memory));</div>
<div class="line"><span class="keywordflow">if</span>(tbl == NULL) <span class="keywordflow">return</span>;</div>
<div class="line"> </div>
<div class="line"><span class="comment">// insert elements (key duplication does not allowed)</span></div>
<div class="line">tbl-&gt;putstr(tbl, <span class="stringliteral">&quot;e1&quot;</span>, <span class="stringliteral">&quot;a&quot;</span>);</div>
<div class="line">tbl-&gt;putstr(tbl, <span class="stringliteral">&quot;e2&quot;</span>, <span class="stringliteral">&quot;b&quot;</span>);</div>
<div class="line">tbl-&gt;putstr(tbl, <span class="stringliteral">&quot;e3&quot;</span>, <span class="stringliteral">&quot;c&quot;</span>);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// debug print out</span></div>
<div class="line">tbl-&gt;debug(tbl, stdout);</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">char</span> *e2 = tbl-&gt;getstr(tbl, <span class="stringliteral">&quot;e2&quot;</span>);</div>
<div class="line"><span class="keywordflow">if</span>(e2 != NULL) {</div>
<div class="line">   printf(<span class="stringliteral">&quot;getstr(&#39;e2&#39;) : %s\n&quot;</span>, e2);</div>
<div class="line">   free(e2);</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Release reference object.</span></div>
<div class="line">tbl-&gt;free(tbl);</div>
<div class="ttc" id="aqhasharr_8c_html_a6f5f9ed05bab0600c251949db75f76f1"><div class="ttname"><a href="qhasharr_8c.html#a6f5f9ed05bab0600c251949db75f76f1">qhasharr</a></div><div class="ttdeci">qhasharr_t * qhasharr(void *memory, size_t memsize)</div><div class="ttdoc">Initialize static hash table.</div><div class="ttdef"><b>Definition</b> <a href="qhasharr_8c_source.html#l00208">qhasharr.c:208</a></div></div>
</div><!-- fragment --><p>An example for using hash table over shared memory.</p>
<div class="fragment"><div class="line">[CREATOR SIDE]</div>
<div class="line"><span class="keywordtype">int</span> maxslots = 1000;</div>
<div class="line"><span class="keywordtype">int</span> memsize = <a class="code hl_function" href="qhasharr_8c.html#a83012ec9fea85ca5770529997306334d">qhasharr_calculate_memsize</a>(maxslots);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// create shared memory</span></div>
<div class="line"><span class="keywordtype">int</span> shmid = <a class="code hl_function" href="qshm_8c.html#a881b11a2d26ae83230151955545630ed">qshm_init</a>(<span class="stringliteral">&quot;/tmp/some_id_file&quot;</span>, <span class="charliteral">&#39;q&#39;</span>, memsize, <span class="keyword">true</span>);</div>
<div class="line"><span class="keywordflow">if</span>(shmid &lt; 0) <span class="keywordflow">return</span> -1; <span class="comment">// creation failed</span></div>
<div class="line"><span class="keywordtype">void</span> *memory = <a class="code hl_function" href="qshm_8c.html#a04d0a8cb2c672f568931132d0c1b5246">qshm_get</a>(shmid);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// initialize hash-table</span></div>
<div class="line">qhasharr_t *tbl = <a class="code hl_function" href="qhasharr_8c.html#a6f5f9ed05bab0600c251949db75f76f1">qhasharr</a>(memory, memsize);</div>
<div class="line"><span class="keywordflow">if</span>(hasharr == NULL) <span class="keywordflow">return</span> -1;</div>
<div class="line"> </div>
<div class="line">(...your codes with your own locking mechanism...)</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Release reference object</span></div>
<div class="line">tbl-&gt;free(tbl);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// destroy shared memory</span></div>
<div class="line"><a class="code hl_function" href="qshm_8c.html#aec816f3889e85322e0304c3cbd67c639">qshm_free</a>(shmid);</div>
<div class="line"> </div>
<div class="line">[USER SIDE]</div>
<div class="line"><span class="keywordtype">int</span> shmid = <a class="code hl_function" href="qshm_8c.html#aa6b1f31987b42fe18dc6be25e58c0bce">qshm_getid</a>(<span class="stringliteral">&quot;/tmp/some_id_file&quot;</span>, <span class="charliteral">&#39;q&#39;</span>);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// get shared memory</span></div>
<div class="line"><span class="keywordtype">void</span> *memory = <a class="code hl_function" href="qshm_8c.html#a04d0a8cb2c672f568931132d0c1b5246">qshm_get</a>(shmid);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// map existing memory into table</span></div>
<div class="line">qhasharr_t *tbl = <a class="code hl_function" href="qhasharr_8c.html#a6f5f9ed05bab0600c251949db75f76f1">qhasharr</a>(memory, 0);</div>
<div class="line"> </div>
<div class="line">(...your codes with your own locking mechanism...)</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Release reference object</span></div>
<div class="line">tbl-&gt;free(tbl);</div>
<div class="ttc" id="aqhasharr_8c_html_a83012ec9fea85ca5770529997306334d"><div class="ttname"><a href="qhasharr_8c.html#a83012ec9fea85ca5770529997306334d">qhasharr_calculate_memsize</a></div><div class="ttdeci">size_t qhasharr_calculate_memsize(int max)</div><div class="ttdoc">Get how much memory is needed for N slots.</div><div class="ttdef"><b>Definition</b> <a href="qhasharr_8c_source.html#l00179">qhasharr.c:179</a></div></div>
<div class="ttc" id="aqshm_8c_html_a04d0a8cb2c672f568931132d0c1b5246"><div class="ttname"><a href="qshm_8c.html#a04d0a8cb2c672f568931132d0c1b5246">qshm_get</a></div><div class="ttdeci">void * qshm_get(int shmid)</div><div class="ttdoc">Get a pointer of shared memory.</div><div class="ttdef"><b>Definition</b> <a href="qshm_8c_source.html#l00149">qshm.c:149</a></div></div>
<div class="ttc" id="aqshm_8c_html_a881b11a2d26ae83230151955545630ed"><div class="ttname"><a href="qshm_8c.html#a881b11a2d26ae83230151955545630ed">qshm_init</a></div><div class="ttdeci">int qshm_init(const char *keyfile, int keyid, size_t size, bool recreate)</div><div class="ttdoc">Initialize shared-memory.</div><div class="ttdef"><b>Definition</b> <a href="qshm_8c_source.html#l00091">qshm.c:91</a></div></div>
<div class="ttc" id="aqshm_8c_html_aa6b1f31987b42fe18dc6be25e58c0bce"><div class="ttname"><a href="qshm_8c.html#aa6b1f31987b42fe18dc6be25e58c0bce">qshm_getid</a></div><div class="ttdeci">int qshm_getid(const char *keyfile, int keyid)</div><div class="ttdoc">Get shared memory identifier by keyfile and keyid for existing shared memory.</div><div class="ttdef"><b>Definition</b> <a href="qshm_8c_source.html#l00127">qshm.c:127</a></div></div>
<div class="ttc" id="aqshm_8c_html_aec816f3889e85322e0304c3cbd67c639"><div class="ttname"><a href="qshm_8c.html#aec816f3889e85322e0304c3cbd67c639">qshm_free</a></div><div class="ttdeci">bool qshm_free(int shmid)</div><div class="ttdoc">De-allocate shared memory.</div><div class="ttdef"><b>Definition</b> <a href="qshm_8c_source.html#l00167">qshm.c:167</a></div></div>
</div><!-- fragment --> 
<p class="definition">Definition in file <a class="el" href="qhasharr_8c_source.html">qhasharr.c</a>.</p>
</div><h2 class="groupheader">Macro Definition Documentation</h2>
<a id="af6ff8340308b20e6f2e5c2f024313c5d" name="af6ff8340308b20e6f2e5c2f024313c5d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af6ff8340308b20e6f2e5c2f024313c5d">&#9670;&#160;</a></span>COLLISION_MARK</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define COLLISION_MARK&#160;&#160;&#160;(-1)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="qhasharr_8c_source.html#l00150">150</a> of file <a class="el" href="qhasharr_8c_source.html">qhasharr.c</a>.</p>

</div>
</div>
<a id="ab725ad48f24a45370685c02f0005a78d" name="ab725ad48f24a45370685c02f0005a78d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab725ad48f24a45370685c02f0005a78d">&#9670;&#160;</a></span>EXTBLOCK_MARK</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define EXTBLOCK_MARK&#160;&#160;&#160;(-2)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="qhasharr_8c_source.html#l00151">151</a> of file <a class="el" href="qhasharr_8c_source.html">qhasharr.c</a>.</p>

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a id="a83012ec9fea85ca5770529997306334d" name="a83012ec9fea85ca5770529997306334d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a83012ec9fea85ca5770529997306334d">&#9670;&#160;</a></span>qhasharr_calculate_memsize()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">size_t qhasharr_calculate_memsize </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>max</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Get how much memory is needed for N slots. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">max</td><td>a number of maximum internal slots</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>memory size needed</dd></dl>
<dl class="section note"><dt>Note</dt><dd>This can be used for calculating minimum memory size for N slots. </dd></dl>

<p class="definition">Definition at line <a class="el" href="qhasharr_8c_source.html#l00179">179</a> of file <a class="el" href="qhasharr_8c_source.html">qhasharr.c</a>.</p>

</div>
</div>
<a id="a6f5f9ed05bab0600c251949db75f76f1" name="a6f5f9ed05bab0600c251949db75f76f1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6f5f9ed05bab0600c251949db75f76f1">&#9670;&#160;</a></span>qhasharr()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">qhasharr_t * qhasharr </td>
          <td>(</td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>memory</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>memsize</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Initialize static hash table. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">memory</td><td>a pointer of data memory. </td></tr>
    <tr><td class="paramname">memsize</td><td>a size of data memory, 0 for using existing data.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>qhasharr_t container pointer, otherwise returns NULL. </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition.<ul>
<li>EINVAL : Assigned memory is too small. It must bigger enough to allocate at least 1 slot.</li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>
<div class="fragment"><div class="line"><span class="comment">// initialize hash-table with 100 slots.</span></div>
<div class="line"><span class="comment">// A single element can take several slots.</span></div>
<div class="line"><span class="keywordtype">char</span> memory[112 * 100];</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Initialize new table.</span></div>
<div class="line">qhasharr_t *tbl = <a class="code hl_function" href="qhasharr_8c.html#a6f5f9ed05bab0600c251949db75f76f1">qhasharr</a>(memory, <span class="keyword">sizeof</span>(memory));</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Use existing table.</span></div>
<div class="line">qhasharr_t *tbl2 = <a class="code hl_function" href="qhasharr_8c.html#a6f5f9ed05bab0600c251949db75f76f1">qhasharr</a>(memory, 0);</div>
</div><!-- fragment --> 
<p class="definition">Definition at line <a class="el" href="qhasharr_8c_source.html#l00208">208</a> of file <a class="el" href="qhasharr_8c_source.html">qhasharr.c</a>.</p>

</div>
</div>
<a id="a6e43029429b7aa43a66d2b55ce3bac81" name="a6e43029429b7aa43a66d2b55ce3bac81"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6e43029429b7aa43a66d2b55ce3bac81">&#9670;&#160;</a></span>qhasharr_put()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool qhasharr_put </td>
          <td>(</td>
          <td class="paramtype">qhasharr_t *&#160;</td>
          <td class="paramname"><em>tbl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>name</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const void *&#160;</td>
          <td class="paramname"><em>data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>datasize</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qhasharr-&gt;<a class="el" href="qhttpclient_8c.html#ae9ac3bd43c11509c0cbd8fb284bf13eb" title="qhttpclient-&gt;put(): Uploads a file to the remote host using PUT method.">put()</a>: Put an object into this table. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>qhasharr_t container pointer. </td></tr>
    <tr><td class="paramname">key</td><td>key string </td></tr>
    <tr><td class="paramname">value</td><td>value object data </td></tr>
    <tr><td class="paramname">size</td><td>size of value</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if successful, otherwise returns false </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition.<ul>
<li>ENOBUFS : Table doesn't have enough space to store the object.</li>
<li>EINVAL : Invalid argument.</li>
<li>EFAULT : Unexpected error. Data structure is not constant. </li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="qhasharr_8c_source.html#l00278">278</a> of file <a class="el" href="qhasharr_8c_source.html">qhasharr.c</a>.</p>

</div>
</div>
<a id="aeadc9cda7a3e29e81a1f11b914c34390" name="aeadc9cda7a3e29e81a1f11b914c34390"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aeadc9cda7a3e29e81a1f11b914c34390">&#9670;&#160;</a></span>qhasharr_putstr()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool qhasharr_putstr </td>
          <td>(</td>
          <td class="paramtype">qhasharr_t *&#160;</td>
          <td class="paramname"><em>tbl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>name</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>data</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qhasharr-&gt;putstr(): Put a string into this table </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>qhasharr_t container pointer. </td></tr>
    <tr><td class="paramname">name</td><td>key string. </td></tr>
    <tr><td class="paramname">data</td><td>value string.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if successful, otherwise returns false </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition.<ul>
<li>ENOBUFS : Table doesn't have enough space to store the object.</li>
<li>EINVAL : Invalid argument.</li>
<li>EFAULT : Unexpected error. Data structure is not constant. </li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="qhasharr_8c_source.html#l00297">297</a> of file <a class="el" href="qhasharr_8c_source.html">qhasharr.c</a>.</p>

</div>
</div>
<a id="a9df103f6016cd3d3267cdf42893ba809" name="a9df103f6016cd3d3267cdf42893ba809"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a9df103f6016cd3d3267cdf42893ba809">&#9670;&#160;</a></span>qhasharr_putstrf()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool qhasharr_putstrf </td>
          <td>(</td>
          <td class="paramtype">qhasharr_t *&#160;</td>
          <td class="paramname"><em>tbl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>name</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>format</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>...</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qhasharr-&gt;putstrf(): Put a formatted string into this table. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>qhasharr_t container pointer. </td></tr>
    <tr><td class="paramname">name</td><td>key string </td></tr>
    <tr><td class="paramname">format</td><td>formatted string data.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if successful, otherwise returns false. </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition.<ul>
<li>ENOBUFS : Table doesn't have enough space to store the object.</li>
<li>ENOMEM : System memory allocation failure.</li>
<li>EINVAL : Invalid argument.</li>
<li>EFAULT : Unexpected error. Data structure is not constant. </li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="qhasharr_8c_source.html#l00316">316</a> of file <a class="el" href="qhasharr_8c_source.html">qhasharr.c</a>.</p>

</div>
</div>
<a id="a3bc56610cce2c4f7ee2373ae4a40143b" name="a3bc56610cce2c4f7ee2373ae4a40143b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3bc56610cce2c4f7ee2373ae4a40143b">&#9670;&#160;</a></span>qhasharr_put_by_obj()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool qhasharr_put_by_obj </td>
          <td>(</td>
          <td class="paramtype">qhasharr_t *&#160;</td>
          <td class="paramname"><em>tbl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const void *&#160;</td>
          <td class="paramname"><em>name</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>namesize</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const void *&#160;</td>
          <td class="paramname"><em>data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>datasize</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qhasharr-&gt;put_by_obj(): ut an object into this table by key object. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>qhasharr_t container pointer. </td></tr>
    <tr><td class="paramname">name</td><td>key data </td></tr>
    <tr><td class="paramname">namesize</td><td>size of key </td></tr>
    <tr><td class="paramname">data</td><td>data </td></tr>
    <tr><td class="paramname">datasize</td><td>size of data</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if successful, otherwise returns false </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition.<ul>
<li>ENOBUFS : Table doesn't have enough space to store the object.</li>
<li>EINVAL : Invalid argument.</li>
<li>EFAULT : Unexpected error. Data structure is not constant. </li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="qhasharr_8c_source.html#l00344">344</a> of file <a class="el" href="qhasharr_8c_source.html">qhasharr.c</a>.</p>

</div>
</div>
<a id="a63f33bbeb824803c310e672f2ceb8c70" name="a63f33bbeb824803c310e672f2ceb8c70"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a63f33bbeb824803c310e672f2ceb8c70">&#9670;&#160;</a></span>qhasharr_get()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void * qhasharr_get </td>
          <td>(</td>
          <td class="paramtype">qhasharr_t *&#160;</td>
          <td class="paramname"><em>tbl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>name</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t *&#160;</td>
          <td class="paramname"><em>datasize</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qhasharr-&gt;<a class="el" href="qhttpclient_8c.html#af16a3eb0912e8b5d4896466632d9c843" title="qhttpclient-&gt;get(): Downloads a file from the remote host using GET method.">get()</a>: Get an object from this table </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>qhasharr_t container pointer. </td></tr>
    <tr><td class="paramname">name</td><td>key string </td></tr>
    <tr><td class="paramname">datasize</td><td>if not NULL, returned object size will be stored</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>malloced object pointer if successful, otherwise(not found) returns NULL </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition.<ul>
<li>ENOENT : No such key found.</li>
<li>EINVAL : Invalid argument.</li>
<li>ENOMEM : Memory allocation failed.</li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>returned object must be freed after done using. </dd></dl>

<p class="definition">Definition at line <a class="el" href="qhasharr_8c_source.html#l00444">444</a> of file <a class="el" href="qhasharr_8c_source.html">qhasharr.c</a>.</p>

</div>
</div>
<a id="a875e900cd73f72bcb613842ddf5b9c3a" name="a875e900cd73f72bcb613842ddf5b9c3a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a875e900cd73f72bcb613842ddf5b9c3a">&#9670;&#160;</a></span>qhasharr_getstr()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">char * qhasharr_getstr </td>
          <td>(</td>
          <td class="paramtype">qhasharr_t *&#160;</td>
          <td class="paramname"><em>tbl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>name</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qhasharr-&gt;getstr(): Finds an object with given name and returns as string type. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>qhasharr_t container pointer. </td></tr>
    <tr><td class="paramname">name</td><td>key string</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>string pointer if successful, otherwise(not found) returns NULL </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition.<ul>
<li>ENOENT : No such key found.</li>
<li>EINVAL : Invalid argument.</li>
<li>ENOMEM : Memory allocation failed.</li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>returned object must be freed after done using. </dd></dl>

<p class="definition">Definition at line <a class="el" href="qhasharr_8c_source.html#l00464">464</a> of file <a class="el" href="qhasharr_8c_source.html">qhasharr.c</a>.</p>

</div>
</div>
<a id="a9334082a845acb3edc1f62d337266acd" name="a9334082a845acb3edc1f62d337266acd"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a9334082a845acb3edc1f62d337266acd">&#9670;&#160;</a></span>qhasharr_get_by_obj()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void * qhasharr_get_by_obj </td>
          <td>(</td>
          <td class="paramtype">qhasharr_t *&#160;</td>
          <td class="paramname"><em>tbl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const void *&#160;</td>
          <td class="paramname"><em>name</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>namesize</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t *&#160;</td>
          <td class="paramname"><em>datasize</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qhasharr-&gt;get_by_object(): Get an object from this table by key object </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>qhasharr_t container pointer. </td></tr>
    <tr><td class="paramname">name</td><td>key data </td></tr>
    <tr><td class="paramname">namesize</td><td>size of key </td></tr>
    <tr><td class="paramname">datasize</td><td>if not NULL, returned object size will be stored</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>malloced object pointer if successful, otherwise(not found) returns NULL </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition.<ul>
<li>ENOENT : No such key found.</li>
<li>EINVAL : Invalid argument.</li>
<li>ENOMEM : Memory allocation failed.</li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>returned object must be freed after done using. </dd></dl>

<p class="definition">Definition at line <a class="el" href="qhasharr_8c_source.html#l00486">486</a> of file <a class="el" href="qhasharr_8c_source.html">qhasharr.c</a>.</p>

</div>
</div>
<a id="aac1f0f336ac79a12590a7f0993e09997" name="aac1f0f336ac79a12590a7f0993e09997"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aac1f0f336ac79a12590a7f0993e09997">&#9670;&#160;</a></span>qhasharr_remove()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool qhasharr_remove </td>
          <td>(</td>
          <td class="paramtype">qhasharr_t *&#160;</td>
          <td class="paramname"><em>tbl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>name</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qhasharr-&gt;remove(): Remove an object from this table. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>qhasharr_t container pointer. </td></tr>
    <tr><td class="paramname">name</td><td>key string</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if successful, otherwise(not found) returns false </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition.<ul>
<li>ENOENT : No such key found.</li>
<li>EINVAL : Invald argument.</li>
<li>EFAULT : Unexpected error. Data structure is not constant. </li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="qhasharr_8c_source.html#l00518">518</a> of file <a class="el" href="qhasharr_8c_source.html">qhasharr.c</a>.</p>

</div>
</div>
<a id="af57be2bc8caf66f6bf94cd21370ef44f" name="af57be2bc8caf66f6bf94cd21370ef44f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af57be2bc8caf66f6bf94cd21370ef44f">&#9670;&#160;</a></span>qhasharr_remove_by_obj()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool qhasharr_remove_by_obj </td>
          <td>(</td>
          <td class="paramtype">qhasharr_t *&#160;</td>
          <td class="paramname"><em>tbl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>name</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>namesize</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qhasharr-&gt;remove_by_obj(): Remove an object from this table by key object </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>qhasharr_t container pointer. </td></tr>
    <tr><td class="paramname">name</td><td>key data </td></tr>
    <tr><td class="paramname">namesize</td><td>size of key</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if successful, otherwise(not found) returns false </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition.<ul>
<li>ENOENT : No such key found.</li>
<li>EINVAL : Invald argument.</li>
<li>EFAULT : Unexpected error. Data structure is not constant. </li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="qhasharr_8c_source.html#l00535">535</a> of file <a class="el" href="qhasharr_8c_source.html">qhasharr.c</a>.</p>

</div>
</div>
<a id="a54fa504cce007a18fa510be544307cab" name="a54fa504cce007a18fa510be544307cab"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a54fa504cce007a18fa510be544307cab">&#9670;&#160;</a></span>qhasharr_remove_by_idx()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool qhasharr_remove_by_idx </td>
          <td>(</td>
          <td class="paramtype">qhasharr_t *&#160;</td>
          <td class="paramname"><em>tbl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>idx</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qhasharr-&gt;remove_by_idx(): Remove an object from this table by index number. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>qhasharr_t container pointer. </td></tr>
    <tr><td class="paramname">idx</td><td>slot index number</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if successful, otherwise(not found) returns false </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition.<ul>
<li>ENOENT : Index is not pointing a valid object.</li>
<li>EINVAL : Invald argument.</li>
<li>EFAULT : Unexpected error. Data structure is not constant.</li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>
<div class="fragment"><div class="line"><span class="keywordtype">int</span> idx = 0;</div>
<div class="line">qhasharr_obj_t obj;</div>
<div class="line"><span class="keywordflow">while</span>(tbl-&gt;getnext(tbl, &amp;obj, &amp;idx) == <span class="keyword">true</span>) {</div>
<div class="line">  <span class="keywordflow">if</span> (condition_to_remove) {</div>
<div class="line">    idx--;  <span class="comment">// adjust index by -1</span></div>
<div class="line">    remove_by_idx(idx);</div>
<div class="line">  }</div>
<div class="line">  free(obj.name);</div>
<div class="line">  free(obj.data);</div>
<div class="line">}</div>
</div><!-- fragment --><dl class="section note"><dt>Note</dt><dd>This function is to remove an object in getnext() traversal loop without knowing the object name but index value. When key names are longer than defined size, the keys are stored with truncation with their fingerprint, so this method provides a way to remove those keys. getnext() returns actual index + 1(pointing next slot of current finding), so you need to adjust it by -1 for the valid index number. And once you remove object by this method, rewind idx by -1 before calling getnext() because collision objects can be moved back to removed index again, so by adjusting index by -1, getnext() can continue search from the removed slot index again. Please refer an example code. </dd></dl>

<p class="definition">Definition at line <a class="el" href="qhasharr_8c_source.html#l00591">591</a> of file <a class="el" href="qhasharr_8c_source.html">qhasharr.c</a>.</p>

</div>
</div>
<a id="a88e2f56b1a87c1f9485f5343ec7998be" name="a88e2f56b1a87c1f9485f5343ec7998be"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a88e2f56b1a87c1f9485f5343ec7998be">&#9670;&#160;</a></span>qhasharr_getnext()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool qhasharr_getnext </td>
          <td>(</td>
          <td class="paramtype">qhasharr_t *&#160;</td>
          <td class="paramname"><em>tbl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">qhasharr_obj_t *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>idx</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qhasharr-&gt;getnext(): Get next element. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>qhasharr_t container pointer. </td></tr>
    <tr><td class="paramname">idx</td><td>index pointer</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>key name string if successful, otherwise(end of table) returns NULL </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition.<ul>
<li>ENOENT : No next element.</li>
<li>EINVAL : Invald argument.</li>
<li>ENOMEM : Memory allocation failed.</li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>
<div class="fragment"><div class="line"><span class="keywordtype">int</span> idx = 0;</div>
<div class="line">qhasharr_obj_t obj;</div>
<div class="line"><span class="keywordflow">while</span>(tbl-&gt;getnext(tbl, &amp;obj, &amp;idx) == <span class="keyword">true</span>) {</div>
<div class="line">  printf(<span class="stringliteral">&quot;NAMESIZE=%zu, DATASIZE=%zu\n&quot;</span>,</div>
<div class="line">         obj.namesize, obj.datasize);</div>
<div class="line">  free(obj.name);  <span class="comment">// key name</span></div>
<div class="line">  free(obj.data);  <span class="comment">// value data</span></div>
<div class="line">}</div>
</div><!-- fragment --><dl class="section note"><dt>Note</dt><dd>Please be aware a key name will be returned with truncated length because key name gets truncated if it doesn't fit into slot size, Q_HASHARR_NAMESIZE. </dd></dl>

<p class="definition">Definition at line <a class="el" href="qhasharr_8c_source.html#l00676">676</a> of file <a class="el" href="qhasharr_8c_source.html">qhasharr.c</a>.</p>

</div>
</div>
<a id="a2a780affb950d666046cfb5e1f9c8153" name="a2a780affb950d666046cfb5e1f9c8153"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2a780affb950d666046cfb5e1f9c8153">&#9670;&#160;</a></span>qhasharr_size()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int qhasharr_size </td>
          <td>(</td>
          <td class="paramtype">qhasharr_t *&#160;</td>
          <td class="paramname"><em>tbl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>maxslots</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>usedslots</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qhasharr-&gt;size(): Returns the number of objects in this table. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>qhasharr_t container pointer. </td></tr>
    <tr><td class="paramname">maxslots</td><td>if not NULL, total number of slots will be stored. </td></tr>
    <tr><td class="paramname">usedslots</td><td>if not NULL, total number of used slots will be stored.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>a number of elements stored. </dd></dl>

<p class="definition">Definition at line <a class="el" href="qhasharr_8c_source.html#l00727">727</a> of file <a class="el" href="qhasharr_8c_source.html">qhasharr.c</a>.</p>

</div>
</div>
<a id="a0c0674e4d7ce39cf336067732ba8cb7b" name="a0c0674e4d7ce39cf336067732ba8cb7b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0c0674e4d7ce39cf336067732ba8cb7b">&#9670;&#160;</a></span>qhasharr_clear()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void qhasharr_clear </td>
          <td>(</td>
          <td class="paramtype">qhasharr_t *&#160;</td>
          <td class="paramname"><em>tbl</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qhasharr-&gt;clear(): Clears this table so that it contains no keys. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>qhasharr_t container pointer.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if successful, otherwise returns false. </dd></dl>

<p class="definition">Definition at line <a class="el" href="qhasharr_8c_source.html#l00750">750</a> of file <a class="el" href="qhasharr_8c_source.html">qhasharr.c</a>.</p>

</div>
</div>
<a id="a6b95b3177af93236950694298df2b7e4" name="a6b95b3177af93236950694298df2b7e4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6b95b3177af93236950694298df2b7e4">&#9670;&#160;</a></span>qhasharr_debug()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool qhasharr_debug </td>
          <td>(</td>
          <td class="paramtype">qhasharr_t *&#160;</td>
          <td class="paramname"><em>tbl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">FILE *&#160;</td>
          <td class="paramname"><em>out</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qhasharr-&gt;debug(): Print hash table for debugging purpose </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>qhasharr_t container pointer. </td></tr>
    <tr><td class="paramname">out</td><td>output stream</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if successful, otherwise returns false </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition.<ul>
<li>EIO : Invalid output stream. </li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="qhasharr_8c_source.html#l00780">780</a> of file <a class="el" href="qhasharr_8c_source.html">qhasharr.c</a>.</p>

</div>
</div>
<a id="aa5cd6756ea7192366386e811c9da8cee" name="aa5cd6756ea7192366386e811c9da8cee"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa5cd6756ea7192366386e811c9da8cee">&#9670;&#160;</a></span>qhasharr_free()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void qhasharr_free </td>
          <td>(</td>
          <td class="paramtype">qhasharr_t *&#160;</td>
          <td class="paramname"><em>tbl</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qhasharr-&gt;free(): De-allocate table reference object. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>qhashtbl_t container pointer.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>This does not de-allocate the data memory but only the memory of qhasharr struct. User provided data memory must be de-allocated by user. </dd></dl>

<p class="definition">Definition at line <a class="el" href="qhasharr_8c_source.html#l00862">862</a> of file <a class="el" href="qhasharr_8c_source.html">qhasharr.c</a>.</p>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_0b61c55142250c0cc363383afd8075a4.html">containers</a></li><li class="navelem"><a class="el" href="qhasharr_8c.html">qhasharr.c</a></li>
    <li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.7 </li>
  </ul>
</div>
</body>
</html>
